<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script>
        var num=prompt("输入你想打印的三角形和平行四边形的行数：");
        //定义变量
        var i,j,h;
        //打印三角形219970413刘慧
        for(i = 1 ; i <= num ; i++){
            for ( j = 1 ; j <= num-i ; j++){
                document.write("&nbsp;");//前面的空格
            }
            for ( k = 1 ; k <= i ; k++){
                document.write("*");//打印*与空格
                document.write("&nbsp;");
            }
            for( j = 1 ; j <= num-i ; j++){
                document.write("&nbsp;");//打印后面的空格
            }
            document.write("<br>")//换行
        }

        //打印平行四边形
        for( i = 1 ; i <= num ; i++){
            for( j = i ; j <= num ; j++){
                document.write("&nbsp;");
            }
            for( k = 1 ; k <= num ; k++){
                document.write("*");
                document.write("&nbsp;");
            }
            document.write("<br>");
        }
    </script>
</head>
<body>  
</body>
</html>